package cn.supermarket.controller;

import cn.supermarket.pojo.vo.PaymentDetailsVO;
import cn.supermarket.pojo.vo.RetailDetailVO;
import cn.supermarket.service.iservice.IPaymentService;
import cn.supermarket.web.JsonResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;
import java.util.List;

@RequestMapping("/payments")
@RestController
@Slf4j
@Api(tags = "付款")
public class PaymentController extends BaseController{
    @Autowired
    private IPaymentService paymentService;
    //修改备注
    @GetMapping("/update/Other")
    @ApiOperation("修改备注")
    public JsonResult<Void> updateByOther(Long id, String other){
        paymentService.updateOther(id, other);
        return JsonResult.ok();
    }

    //修改是否可见
    @GetMapping("/update/display")
    @ApiOperation("修改是否可见")
    public JsonResult<Void> updateByIsDisplay(Long id,Integer isDisplay){
        paymentService.updateIsDisplay(id,isDisplay);
        return JsonResult.ok();
    }
    //作废
    @GetMapping("/update/cancel")
    @ApiOperation("作废")
    public JsonResult<Void> updateByIsCancel(Long id) {
        paymentService.updateIsCancel(id);
        return JsonResult.ok();
    }
    //根据订单号查询
    @GetMapping("/select/order-number")
    @ApiOperation("订单号查询")
    public JsonResult<PaymentDetailsVO> getByOrderNumber(String orderNumber){
        return JsonResult.ok(paymentService.getOrderNumber(orderNumber));
    }

    //根据日期查询
    @GetMapping("/select/data")
    @ApiOperation("日期查询")
    public JsonResult<List<PaymentDetailsVO>> getByData(Date dateStart, Date dateEnd){
        return JsonResult.ok(paymentService.getData(dateStart,dateEnd));
    }

    //根据收款方查询
    @GetMapping("/select/payer")
    @ApiOperation("收款方查询")
    public JsonResult<List<PaymentDetailsVO>> getByPayer(String payer){
        return JsonResult.ok(paymentService.getPayer(payer));
    }

    //付款方
    @GetMapping("/select/payee")
    @ApiOperation("收款方查询")
    public JsonResult<List<PaymentDetailsVO>> getByPayee(String payee){
        return JsonResult.ok(paymentService.getPayee(payee));
    }
}
